package com.project.interceptor;

import com.project.bean.UserBean;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RoomInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        UserBean user = (UserBean) request.getSession().getAttribute("loginUser");
        if (user.getLevel().equals("班主任")||user.getLevel().equals("系统管理员")) {
            response.sendRedirect("/homehtml/homePage.html");
            return false;
        } else {
            return true;
        }
    }
}
